//
//  ParttakeViewController.m
//  YunGou
//
//  Created by macbook on 16/5/23.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "ParttakeViewController.h"
#import "ParttakeCell.h"
#import "EnjoyRecordModel.h"
#import "NSObject+Tools.h"

@interface ParttakeViewController ()
@property (nonatomic,strong) NSMutableArray *dataArray;
@end

@implementation ParttakeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _dataArray = [NSMutableArray array];
    [NetWorkTool enjoyRecordWithGoodsId:_goodsId success:^(id object) {
        if ([object[@"code"] integerValue] == 1) {
            for (NSDictionary *dict in object[@"data"]) {
                EnjoyRecordModel *model = [EnjoyRecordModel modelWithDict:dict];
                [_dataArray addObject:model];
            }
        }
        [self.tableView reloadData];
    } failure:^(NSError *error) {
        
    }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ParttakeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.partakeModel = _dataArray[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 65;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
